#include "tcpServer.hpp"
#include "daemon.hpp"
#include <memory>

using namespace Server;
using namespace std;

static void Usage(const std::string &proc)
{
    std::cout << "\nUsage:\n\t" << proc << " local_port" << std::endl
              << std::endl;
}

int main(int argc, char* argv[])
{
    if (argc != 2)
    {
        Usage(argv[0]);
        exit(USAGE_ERROR);
    }

    // 1.
    uint16_t port = atoi(argv[1]);
    unique_ptr<tcpServer> tsr(new tcpServer(port));

    // 2.
    tsr->init();

    // 3.
    my_daemon();// 使成为守护进程

    tsr->start();

    return 0;
}